{include file="common/header"/}
<!--页面单独CSS-->
<link href="__DEMO__/css/login.css" rel="stylesheet">
<!--页面单独JS-->
<script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <!--<h1>河南欧骥网络有限公司</h1>-->
                </div>
                <div class="m-b"></div>
                <!--<h4>欢迎使用 <strong>H+ 后台主题UI框架</strong></h4>-->
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势一</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势二</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势三</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势四</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势五</li>
                </ul>
                <!--<strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>-->
            </div>
        </div>
        <div class="col-sm-5">
            <form>
                <h4 class="no-margins">登录：</h4>
                <!--<p class="m-t-md">登录到H+后台主题UI框架</p>-->
                <input type="text" name="username" id="username" class="form-control uname" placeholder="用户名" />
                <input type="password" name="password" id="password" class="form-control pword m-b" placeholder="密码" />
                <!--<a href="">忘记密码了？</a>-->
                <input type="button"  class=" btn btn-success btn-block submit login" value="登&nbsp;&nbsp;&nbsp;录">
                <!--<button class="btn btn-success btn-block  submit login">登录</button>-->
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2015 All Rights Reserved. H+
        </div>
    </div>
    <script>
        $(document).ready(function(){
            layui.use('form', function () {
                function submitLogin(){
                    var username = $('#username').val();
                    var password = $('#password').val();

                    if(username.length == 0 ) {
                        layer.msg('登录用户名不能为空'); return;
                    }
                    if(password.length == 0 ) {
                        layer.msg('登录密码错误'); return;
                    }
                    $.ajax({
                        url: '{:url("/printer/login/postLogin")}',
                        type: 'post',
                        dataType: 'json',
                        data: {username:username,password:password},
                        cache: false,
                        async: true,
                        beforeSend: function () {
                            var index = layer.load(1, {
                                shade: [0.1, '#fff'], time: 3 * 1000 //0.1透明度的白色背景
                            });
                        },
                        complete: function () {
                            layer.closeAll('loading');
                        },
                        success: function (res) {
                            if (res.code) {
                                layer.msg('登录成功,请稍后...', {icon: 1});
                                window.location.href = '{:url("/printer/index/index")}';
                                return false;
                            } else {
                                layer.msg('用户名或者密码错误...', {icon: 5});
                                return  false;
                            }
                            return false;
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert('网络失败，请联系管理员', {icon: 2});
                        }
                    });
                }
                //点击登录
                $(document).on('click','.submit',function(){
                    submitLogin()
                });
                //回车登录
                $(document).keydown(function(event){
                    if(event.keyCode == 13){
                        submitLogin();
                    }
                });
            });
        })
    </script>
</div>
</body>
</html>
